﻿function doLogin() {
    var username = $.trim($("#username").val());
    var password = $.trim($("#password").val());
    if (username && password) {
        $("#error-container").hide();
        $.ajax({
            url: '/admin/user/dologin',
            async: false,
            cache: false,
            type: "post",
            dataType: "json",
            data: "username="+escape(username)+"&password="+escape(password),
            success: function (result) {
                if (result.status) {
                    location.href = result.url;
                } else {
                    $("#error-message").html(result.message);
                    $("#error-container").show();
                }
            }
        });
    }
    else {
        $("#error-message").html("请输入用户名和密码");
        $("#error-container").show();
    }
}